<!doctype html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
	<head>
		<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
		<meta http-equiv="content-script-type" content="text/javascript">
		<meta http-equiv="content-style-type" content="text/css">
		<meta name="author" content="Heidi Rakels">
		<meta name="description" content="Sanaware Java Docking - Developer guide - Dock Models">
		<link rel="stylesheet" type="text/css" href="../style.css">
		<title>How to Use Dock Models</title>
	</head>
<body>

<div class="nextprev">
<nobr><a href="visualizer.html">&laquo; prev</a></nobr>
<nobr><a href="dockingpath.html">next &raquo;</a></nobr>
</div>

<span class="item"><a href="../main/index.html">Java Docking Home</a></span>&gt;
<span class="item"><a href="index.html">Developer Guide</a></span>&gt;
<span class="selected item">How to Use Dock Models</span>

<h2>
How to Use Dock Models
</h2>

<h3>
:: Dock Model ::
</h3>
<p>
A <a href="../javadoc/com/javadocking/model/DockModel.html" target="_blank">DockModel</a> 
contains the structure of all the <a href="../javadoc/com/javadocking/dock/Dock.html" target="_blank">
Dock</a> and <a href="../javadoc/com/javadocking/dockable/Dockable.html" target="_blank">
Dockable</a> objects that are used in an application. It contains also the 
<a href="../javadoc/com/javadocking/visualizer/Visualizer.html" target="_blank">Visualizer</a>s
that are used in the application.
</p>
<p>
The structure of docks and dockables in an application is like this:
<ul>
<li>
Every dockable that is visible, is docked in a <a href="../javadoc/com/javadocking/dock/LeafDock.html" target="_blank">
LeafDock</a>.
Every dockable knows its leaf dock:
<blockquote><pre>
		LeafDock leafDock = dockable.getDock();
</pre></blockquote>
</li>
<li>
Docks can be docked in other <a href="../javadoc/com/javadocking/dock/CompositeDock.html" target="_blank">
CompositeDock</a> objects.
Every dock knows its parent composite dock:
<blockquote><pre>
		CompositeDock parentDock = dock.getParentDock();
</pre></blockquote>
</li>
<li>	
A root dock is a dock whose parent dock is null.
</li>
</ul>		
An application contains trees of docks.
The dock model only needs to know all the root docks.
With this information all the docks and dockables can be retrieved.
</p>

<h3>
:: The owner window of docks and visualizers ::
</h3>
<p>
You have to give all the java.awt.Window objects (javax.swing.JFrame or javax.swing.JDialog), 
where you will put docks to the dock model with a unique ID.
<blockquote><pre>
		// Create the dock model for the docks.
		FloatDockModel dockModel = new FloatDockModel();
		dockModel.addOwner("frame0", frame);
</pre></blockquote>
When you add a root dock to the model you have to specify its ancestor window:
<blockquote><pre>
		// Add the root dock to the dock model.
		dockModel.addRootDock("totaldock", totalSplitDock, frame);
</pre></blockquote>
When you add a visualizer (minimizer or maximizer) to the model you have to specify its window:
<blockquote><pre>
			// Add the maximizer to the dock model.
			dockModel.addVisualizer("maximizer", maximizer, frame);
			...
			// Add the minimizer to the dock model.
			dockModel.addVisualizer("minimizer", minimizer, frame);
</pre></blockquote>
</p>

<a name="FloatDockModel"><!-- --></a>
<h3>
:: Float Dock Model ::
</h3>
<p>
The most used DockModel implementation is the <a href="../javadoc/com/javadocking/model/FloatDockModel.html" target="_blank">
FloatDockModel</a>.
This dock model creates by default a FloatDock for every owner
window, that you add to the model.
</p>
<p>
You can give a <a href="../javadoc/com/javadocking/model/FloatDockFactory.html" target="_blank">
FloatDockFactory</a> to your float dock model.
This factory will be used to create your custom float docks.
<blockquote><pre>
	{
		...
		
		// Create the factory for the float docks.
		FloatDockFactory floatDockFactory = new MyFloatDockFactory();

		// Create the dock model for the docks.
		FloatDockModel dockModel = new FloatDockModel(floatDockFactory);

		...
	}
	
	
	private class MyFloatDockFactory extends DefaultFloatDockFactory
	{

		public FloatDock createFloatDock(Window owner)
		{
			FloatDock floatDock = super.createFloatDock(owner);
			
			// We want a higher priority for making dockables float.
			floatDock.setDockPriority(DockPriority.CAN_DOCK_WITH_PRIORITY);
			
			return floatDock;
		}
		
	}
</pre></blockquote>
</p>

<hr>

<br/>
The source code of the samples can be found in:
<br/><br/>
<table>
<tr>
	<td><a href="code/CodecExample.java.html">CodecExample</a></td><td>Shows the usage, the encoding, and the decoding of dock models.</td>
</tr>
<tr>
	<td><a href="code/WorkspaceExample.java.html">WorkspaceExample</a></td><td>Shows the usage, the encoding, and the decoding of dock models.</td>
</tr>
</table>

<br/>
<hr>
<br/>

<div class="nextprevbottom">
<nobr><a href="visualizer.html">&laquo; prev</a></nobr>
<nobr><a href="dockingpath.html">next &raquo;</a></nobr>
</div>

</body>

</html>